/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Com.agenceLocation.bdd;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Yohan
 */
@Entity
@Table(name = "VEHICULE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Vehicule.findAll", query = "SELECT v FROM Vehicule v"),
    @NamedQuery(name = "Vehicule.findById", query = "SELECT v FROM Vehicule v WHERE v.id = :id"),
    @NamedQuery(name = "Vehicule.findByName", query = "SELECT v FROM Vehicule v WHERE v.name = :name"),
    @NamedQuery(name = "Vehicule.findByBorn", query = "SELECT v FROM Vehicule v WHERE v.born = :born"),
    @NamedQuery(name = "Vehicule.findByEcovalue", query = "SELECT v FROM Vehicule v WHERE v.ecovalue = :ecovalue"),
    @NamedQuery(name = "Vehicule.findByPicture", query = "SELECT v FROM Vehicule v WHERE v.picture = :picture")})
public class Vehicule implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 4000)
    @Column(name = "NAME")
    private String name;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 4000)
    @Column(name = "BORN")
    private String born;
    @Column(name = "ECOVALUE")
    private Integer ecovalue;
    @Size(max = 4000)
    @Column(name = "PICTURE")
    private String picture;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "vehiculeId")
    private Collection<Location> locationCollection;

    public Vehicule() {
    }

    public Vehicule(Integer id) {
        this.id = id;
    }

    public Vehicule(Integer id, String name, String born) {
        this.id = id;
        this.name = name;
        this.born = born;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getBorn() {
        return born;
    }

    public void setBorn(String born) {
        this.born = born;
    }

    public Integer getEcovalue() {
        return ecovalue;
    }

    public void setEcovalue(Integer ecovalue) {
        this.ecovalue = ecovalue;
    }

    public String getPicture() {
        return picture;
    }

    public void setPicture(String picture) {
        this.picture = picture;
    }

    @XmlTransient
    public Collection<Location> getLocationCollection() {
        return locationCollection;
    }

    public void setLocationCollection(Collection<Location> locationCollection) {
        this.locationCollection = locationCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Vehicule)) {
            return false;
        }
        Vehicule other = (Vehicule) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Com.agenceLocation.bdd.Vehicule[ id=" + id + " ]";
    }
    
}
